import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import 'normalize.css/normalize.css' // 规范 CSS

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import '@/permission.js' // 导入权限控制

const app = createApp(App)

//从 @element-plus/icons-vue 中导入所有图标并进行全局注册
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 全局方法
app.config.globalProperties.$fullUrl = (urlPath) => {
	// console.log(urlPath)
  if (!urlPath) return urlPath
  //如果包含http字符串，直接返回
  if (urlPath.startsWith("http")) {
    return urlPath;
  }
  //加上BaseAPI生成图片完整Url
  return `${import.meta.env.VITE_BASE_API}${urlPath}`;
}

app
	.use(store)
  .use(router)
	.use(ElementPlus, { zIndex: 1000 , locale: zhCn})
	.mount('#app')
